import agentHttp from '@/utils/agentHttp.js';
export  function images_basic_supplier_first(_this){
	return  new Promise ( function (resolve, reject) { 
		var selectFunder;
		agentHttp.get('adminApi/admin/car_order/first_audit_order/'+_this.carOrderId).then((data)=>{
		    if(data.success){  
                var qiniuImage={
		        	id:"qiniuImage100", //图片预览的id   
		        	image_uri:[],    //图片上传的列表  只含有url地址
		        },
		        
		        qiniuImage1={
		        	id:"qiniuImage101",    
		        	image_uri:[]
		        },
		        
		        qiniuImage2={
		        	id:"qiniuImage102",    
		        	image_uri:[]
		        },
		        
		        qiniuImage3={
		        	id:"qiniuImage103",    
		        	image_uri:[]
		        },
		        
		        qiniuImage4={
		        	id:"qiniuImage104",    
		        	image_uri:[]
		        },
		        qiniuImage5={
		        	id:"qiniuImage105",    
		        	image_uri:[]
		        },
		        qiniuImage6={
		        	id:"qiniuImage106",    
		        	image_uri:[]
		        },
		        qiniuImage7={
		        	id:"qiniuImage107",    
		        	image_uri:[]
		        };
		      _this.dialogForm =  data.data.orderInfo;  
		      //资金方
		      _this.selectFunder = data.data.funderUser;
		      selectFunder=data.data.funderUser;

		      if(_this.dialogForm.orderAuditResults == null){
		      	 _this.dialogForm.orderAuditResults = {}; 
		      }else{
		      	_this.dialogForm.orderAuditResults.examineAptitudePic?qiniuImage4.image_uri=_this.dialogForm.orderAuditResults.examineAptitudePic.split(',').notempty():"";
		    	_this.dialogForm.orderAuditResults.resourceProviderPic?qiniuImage5.image_uri=_this.dialogForm.orderAuditResults.resourceProviderPic.split(',').notempty():"";
		    	_this.dialogForm.orderAuditResults.carInformationPic?_this.qiniuImage7.image_uri=_this.dialogForm.orderAuditResults.carInformationPic.split(',').notempty():"";
		      }     
		      //初始化业务员
		      _this.yewuyuan=data.data.yewuyuan;
		      //初始化地推人员 
		      _this.ditui= data.data.ditui;
		      //初始化订单类型
		      _this.orderType= data.data.orderType;
		      _this.dialogForm.orderAuditResults.proceduresSendTime?_this.dialogForm.orderAuditResults.proceduresSendTime=new Date(_this.dialogForm.orderAuditResults.proceduresSendTime):"";
		     
		      //加载图片
		        _this.dialogForm.contracts?qiniuImage.image_uri= _this.dialogForm.contracts.split(',').notempty():"";
		    	_this.dialogForm.depositPic?qiniuImage1.image_uri= _this.dialogForm.depositPic.split(',').notempty():"";
		    	_this.dialogForm.supplierInfoPic?qiniuImage2.image_uri= _this.dialogForm.supplierInfoPic.split(',').notempty():"";
		    	_this.dialogForm.supplierAddressPic?qiniuImage3.image_uri= _this.dialogForm.supplierAddressPic.split(',').notempty():"";
		    	_this.dialogForm.supplementPic?qiniuImage6.image_uri= _this.dialogForm.supplementPic.split(',').notempty():"";
		    	_this.$nextTick(function(){
		    		getSpvUser();
		    		eventHub.$emit('eventHub', { 
			    		qiniuImage:qiniuImage,
			    		qiniuImage1:qiniuImage1,
			    		qiniuImage2:qiniuImage2,
			    		qiniuImage3:qiniuImage3,
			    		qiniuImage4:qiniuImage4,
			    		qiniuImage5:qiniuImage5,
			    		qiniuImage6:qiniuImage6,
			    		dialogForm:_this.dialogForm,
			    		orderType: _this.orderType,
			    		yewuyuan: _this.yewuyuan,
			    		ditui:_this.ditui,
			    		selectSpvUser:_this.selectSpvUser,
			    		selectFunder:_this.selectFunder

			    		
			    	});
		    	})
		    	
		    	
		    	
		    	
		        _this.dialogForm.orderAuditResults.carInformationExamineResult=_this.dialogForm.orderAuditResults.carInformationExamineResult==null?"确认无误":_this.dialogForm.orderAuditResults.carInformationExamineResult; 
		    	if(_this.isAdd.bool){
		    		_this.dialogForm.status=30;

		    	}
		    	resolve(true)
		    	//_this.dialogForm.orderAuditResults.proceduresSendTime?_this.dialogForm.orderAuditResults.proceduresSendTime=new Date(_this.dialogForm.orderAuditResults.proceduresSendTime):"";
		    	
		    }else{
		    	reject(err)
		    }
		})
		function getSpvUser(){ 
			for (var i = 0; i < _this.selectFunder.length; i++) {
				if( _this.selectFunder[i].id == _this.dialogForm.funderId ){  
					if(null != _this.selectFunder[i].spv){
						_this.selectSpvUser = _this.selectFunder[i].spv;   
						_this.dialogForm.spvId = parseInt(_this.selectFunder[i].spv.id);
						return ;
					}else {
						_this.dialogForm.spvId=null;
						_this.selectSpvUser ={};
					}
				}else{
					    _this.dialogForm.spvId=null;
						_this.selectSpvUser ={};
				}  
			} 
		}
		
    })
}
